﻿using System;
using System.Collections.Generic;
using Newtonsoft.Json;
using UnityEngine;

namespace Runtime.Net {

    [JsonObject(MemberSerialization.OptIn)]
    public sealed class DFR_NetRemoteSettings {

        [JsonProperty]
        private List<DFR_NetRemoteSetting> m_List;

        private IDictionary<string, DFR_NetRemoteSetting> m_Dictionary;
        public DFR_NetRemoteSetting Get(string name) {
            if (m_Dictionary == null) {
                m_Dictionary = new Dictionary<string, DFR_NetRemoteSetting>();
                foreach (var item in m_List) {
                    m_Dictionary[item.Name] = item;
                }
            }
            return m_Dictionary[name];
        }
    }

    [Serializable]
    [JsonObject(MemberSerialization.OptIn)]
    public sealed class DFR_NetRemoteSetting {

        [Serializable]
        [JsonObject(MemberSerialization.OptIn)]
        public sealed class ShareImageSetting {

            [SerializeField]
            [JsonProperty]
            private string m_Key;
            public string Key {
                get => m_Key;
                init => m_Key = value;
            }

            [SerializeField]
            [JsonProperty]
            private string m_URL;
            public string URL {
                get => m_URL;
                init => m_URL = value;
            }
        }

        [Serializable]
        [JsonObject(MemberSerialization.OptIn)]
        public sealed class FeatureSetting {

            [SerializeField]
            [JsonProperty]
            private bool m_Share;
            public bool Share {
                get => m_Share;
                init => m_Share = value;
            }

            [SerializeField]
            [JsonProperty]
            private bool m_SideBar;
            public bool SideBar {
                get => m_SideBar;
                init => m_SideBar = value;
            }

            [SerializeField]
            [JsonProperty]
            private bool m_Desktop;
            public bool Desktop {
                get => m_Desktop;
                init => m_Desktop = value;
            }

            [SerializeField]
            [JsonProperty]
            private bool m_GameClub;
            public bool GameClub {
                get => m_GameClub;
                init => m_GameClub = value;
            }

            [SerializeField]
            [JsonProperty]
            private bool m_AddMiniProgram;
            public bool AddMiniProgram {
                get => m_AddMiniProgram;
                init => m_AddMiniProgram = value;
            }

            [SerializeField]
            [JsonProperty]
            private bool m_Subscribe;
            public bool Subscribe {
                get => m_Subscribe;
                init => m_Subscribe = value;
            }
        }

        [Serializable]
        [JsonObject(MemberSerialization.OptIn)]
        public sealed class ConnectionSetting {

            [SerializeField]
            [JsonProperty]
            private string m_URL;
            public string URL {
                get => m_URL;
                init => m_URL = value;
            }

            [SerializeField]
            [JsonProperty]
            private string m_Platform;
            public string Platform {
                get => m_Platform;
                init => m_Platform = value;
            }

            [SerializeField]
            [JsonProperty]
            private string m_Extra;
            public string Extra {
                get => m_Extra;
                init => m_Extra = value;
            }
        }

        [SerializeField]
        [JsonProperty]
        private string m_Name;
        public string Name {
            get => m_Name;
            init => m_Name = value;
        }

        [SerializeField]
        [JsonProperty]
        private string m_AppName;
        public string AppName {
            get => m_AppName;
            init => m_AppName = value;
        }

        [SerializeField]
        [JsonProperty]
        private string m_APPID;
        public string APPID {
            get => m_APPID;
            init => m_APPID = value;
        }

        [SerializeField]
        [JsonProperty]
        private string m_CDNURL;
        public string CDNURL {
            get => m_CDNURL;
            init => m_CDNURL = value;
        }

        [SerializeField]
        [JsonProperty]
        private ConnectionSetting m_Connection;
        public ConnectionSetting Connection {
            get => m_Connection;
            init => m_Connection = value;
        }

        [SerializeField]
        [JsonProperty]
        private bool m_IsDebug = true;
        public bool IsDebug {
            get => m_IsDebug;
            init => m_IsDebug = value;
        }

        [SerializeField]
        [JsonProperty]
        private bool m_IsDebugAD = false;
        public bool IsDebugAD {
            get => m_IsDebugAD;
            init => m_IsDebugAD = value;
        }

        [SerializeField]
        [JsonProperty]
        private string m_RewardAD;
        public string RewardAD {
            get => m_RewardAD;
            init => m_RewardAD = value;
        }

        [SerializeField]
        [JsonProperty]
        private string m_NoSDKEnvTag;
        public string NoSDKEnvTag {
            get => m_NoSDKEnvTag;
            init => m_NoSDKEnvTag = value;
        }

        [JsonProperty]
        private List<ShareImageSetting> m_ShareImageList;
        public IReadOnlyList<ShareImageSetting> ShareImageList {
            get => m_ShareImageList;
            init => m_ShareImageList = (List<ShareImageSetting>)value;
        }

        [SerializeField]
        [JsonProperty]
        private FeatureSetting m_Feature;
        public FeatureSetting Feature {
            get => m_Feature;
            init => m_Feature = value;
        }

        [JsonProperty]
        private Dictionary<string, string> m_ExtraDataDictionary;
        public IReadOnlyDictionary<string, string> ExtraDataDictionary {
            get => m_ExtraDataDictionary;
            init => m_ExtraDataDictionary = (Dictionary<string, string>)value;
        }
    }
}
